package com.simple.gateway.center.web;

import com.simple.gateway.center.application.IAuthService;
import com.simple.gateway.center.basedata.common.Result;
import com.simple.gateway.center.domian.auth.dto.AuthTokenInfoDTO;
import com.simple.gateway.center.domian.auth.param.AuthTokenParam;
import com.simple.gateway.center.domian.auth.param.BindInterfacesParam;
import com.simple.gateway.center.domian.auth.param.ChangeAuthParam;
import com.simple.gateway.center.domian.auth.param.GatewayUserFullParam;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * 项目: simple-gateway-core
 *
 * 功能描述:
 *
 * @author: WuChengXing
 *
 * @create: 2023-08-31 15:15
 **/
@RestController
@RequestMapping("/gateway/api/auth")
@CrossOrigin
public class AuthManageController {

    @Resource
    private IAuthService authService;

    @PostMapping("/registerUser")
    public Result<Boolean> registerUser(@RequestBody GatewayUserFullParam param) {
        return Result.success(authService.registerUser(param));
    }

    @PostMapping("/bindInterfaces")
    public Result<Boolean> bindInterfaces(@RequestBody BindInterfacesParam param) {
        return Result.success(authService.bindInterfaces(param));
    }

    @PostMapping("/changeAuthInto")
    public Result<Boolean> changeAuthInto(@RequestBody ChangeAuthParam param) {
        return Result.success(authService.changeAuthInto(param));
    }

    @PostMapping("/generateToken")
    public Result<AuthTokenInfoDTO> generateToken(@RequestBody AuthTokenParam param) {
        return Result.success(authService.generateToken(param));
    }
}
